package com.yangquan.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yangquan.bean.Employee;
import com.yangquan.service.EmployeeService;

@Controller
public class EmployeeController {
	
	@Autowired
	EmployeeService employeeService;
	
	
	@RequestMapping("/emps")
	public String getEmps(@RequestParam(value="pn",defaultValue="1")Integer pn,Model model) {
		//mybatis 的分页插件
		// startPage(页码, 显示数据数量)
		PageHelper.startPage(pn, 5);
		//员工信息
		List<Employee> emps = employeeService.getAll();
		//pageInfo
		//连续显示页数
		PageInfo page=new PageInfo<>(emps,5);
		//把分页信息存放到模型中
		model.addAttribute("pageInfo", page);
		
		return "list";
	}
	
	
	
}
